<template>
  <div class="film-item">
    <div class="poster">
      <img :src="data.poster" alt="" />
    </div>

    <div class="info">
      <p class="info-item info-item__name">
        {{ data.name }}
        <span class="tag">3D</span>
      </p>
      <p class="info-item" v-visible="data.grade">
        观众评分 <span>{{ data.grade }}</span>
      </p>
      <p class="info-item">主演：{{ displayActors }}</p>
      <p class="info-item">{{ data.nation }} | {{ data.runtime }}分钟</p>
    </div>

    <div class="handle">
      <van-button class="buy">购票</van-button>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { computed } from "vue";

const props = defineProps<{
  data: IFilm;
}>();

const displayActors = computed(() => {
  if (props.data.actors) {
    return props.data.actors.map((item) => item.name).join(" ");
  } else {
    return "暂无主演";
  }
});
</script>

<style lang="scss" scoped>
.film-item {
  padding: 15px 15px 15px 15px;
  height: 94px;
  display: flex;
  position: relative;
}

.poster {
  width: 66px;
  height: 94px;
  background: green;

  img {
    display: block;
    width: 100%;
  }
}

.info {
  flex: 1;
  padding: 0 10px;
  overflow: hidden;
}

.handle {
  display: flex;
  align-items: center;
}

.info-item {
  margin: 0;
  font-size: 14px;
  color: #797d82;
  line-height: 20px;
  // 出现...
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;

  span {
    color: #ffb232;
  }

  .tag {
    margin-left: 5px;
    font-size: 9px;
    color: #fff;
    background-color: #d2d6dc;
    height: 14px;
    line-height: 14px;
    padding: 0 2px;
    border-radius: 2px;
  }

  &__name {
    display: inline-flex;
    align-items: center;
    color: #000;
    line-height: 30px;
  }
}

.buy {
  height: 26px;
  color: var(--van-primary-color);
  border-color: var(--van-primary-color);
}
</style>
